const bodyParser =require('body-parser')
const {data} =require('./src/mock')

module.exports={
    devServer:{
        before:app=>{
            app.use(bodyParser.json())
            app.post('/api/add',(req,res)=>{
                // console.log(req.body)
                const value=req.body
                data.push(value)
                // console.log(data)
                res.send({
                    code:200,
                    data
                })
            })
            app.post('/api/delete',(req,res)=>{
                console.log(req.body)
                // const {id}=req.body
                let newdata=data.filter(item=>item.id!==id)
                console.log(data)
                res.send({
                    code:200,
                    data:newdata
                })
            })
        }
    }
}